| Author |
Topic |
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-01-30 : 07:39:52
|
| hi,how can I display '2008-01-19' using getdate() and date functions ?also display '2007-11-20' from getdate() ? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-30 : 07:41:10
|
check out convert() or do the formatting in your front end application KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-30 : 07:43:20
|
| Where do you want to show data?MadhivananFailing to plan is Planning to fail |
 |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2008-01-30 : 07:43:45
|
| hi, thanks,but I just had a brain wave and worked it out like :--SET @Date3 = '2007-11-19'SET @Date3 = DATEADD(mm,-2,DATEADD(dd,18,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)))--SET @Date1 = '2007-12-20'SET @Date1 = DATEADD(mm,-1,DATEADD(dd,19,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)))--SET @Date2 = '2008-01-19'SET @Date2 = DATEADD(dd,18,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))! cheers. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-30 : 07:48:14
|
quote: Originally posted by jamie hi, thanks,but I just had a brain wave and worked it out like :--SET @Date3 = '2007-11-19'SET @Date3 = DATEADD(mm,-2,DATEADD(dd,18,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)))--SET @Date1 = '2007-12-20'SET @Date1 = DATEADD(mm,-1,DATEADD(dd,19,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)))--SET @Date2 = '2008-01-19'SET @Date2 = DATEADD(dd,18,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))! cheers.
what are you trying to achieve here ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mightypenny_ph
Yak Posting Veteran
54 Posts |
Posted - 2008-01-30 : 08:12:27
|
| select convert(varchar, getdate(), 102) - 2008.01.01SlayerS_`BoxeR` + [ReD]NaDa |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-30 : 09:32:32
|
quote: Originally posted by jamie hi, thanks,but I just had a brain wave and worked it out like :--SET @Date3 = '2007-11-19'SET @Date3 = DATEADD(mm,-2,DATEADD(dd,18,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)))--SET @Date1 = '2007-12-20'SET @Date1 = DATEADD(mm,-1,DATEADD(dd,19,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)))--SET @Date2 = '2008-01-19'SET @Date2 = DATEADD(dd,18,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))! cheers.
Good. Setting Time part to 0 is the effecient wayMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|