Author |
Topic |
reflex2dotnet
Yak Posting Veteran
99 Posts |
Posted - 2007-02-12 : 13:23:33
|
Hi EverybodyI am trying to get some function which returns- current month name- current year- date range ( for February displaying 2/1/2007 - 2/28/2007)-year range ( 1 Jan 2007 - 31 Dec 2007)I was wondering, is there any functions for these?I searched a lot, but couldnt find a solutionIt will be really greatful if someone can help me in this.Thanks |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-12 : 13:31:01
|
1) select datename(month, getdate())2) select datepart(year, getdate())Peter LarssonHelsingborg, Sweden |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-12 : 13:36:22
|
3) select convert(varchar, dateadd(month, datediff(month, 0, getdate()), 0), 101) + ' - ' + convert(varchar, dateadd(month, 1 + datediff(month, 0, getdate()), -1), 101)Peter LarssonHelsingborg, Sweden |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-12 : 13:37:57
|
4) select convert(varchar, dateadd(year, datediff(year, 0, getdate()), 0), 106) + ' - ' + convert(varchar, dateadd(year, 1 + datediff(year, 0, getdate()), -1), 106)Peter LarssonHelsingborg, Sweden |
 |
|
reflex2dotnet
Yak Posting Veteran
99 Posts |
Posted - 2007-02-12 : 13:45:47
|
This is a great help.But sorry to say this that, can you please tel me how can i use this as a function so that i can set a label text to these select statements resultseg. lblDate = ?Do i need to make any user defined functions or stored procedures with these select stmt? |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-12 : 14:10:48
|
No, you must use the FORMAT function and NOW function if formatting the text in front-end application.Why do you fool us and make us think you want help with T-SQL, when you really want help with VB/ASP formatting?Peter LarssonHelsingborg, Sweden |
 |
|
reflex2dotnet
Yak Posting Veteran
99 Posts |
Posted - 2007-02-12 : 14:16:21
|
I am really sorry for this.I actually thought that as it is a function, I will ask in T-SQLI didnt really mean to confuse youSorry for this |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-12 : 14:24:57
|
It is faster to do in front-end application.1) FORMAT(Now, "mmm")2) FORMAT(Now, "yyyy")Peter LarssonHelsingborg, Sweden |
 |
|
reflex2dotnet
Yak Posting Veteran
99 Posts |
Posted - 2007-02-12 : 15:02:20
|
Thanks Sorry once againWill be conscious before posting |
 |
|
|