Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
TPie9
Yak Posting Veteran
67 Posts |
Posted - 2010-09-23 : 12:23:45
|
| I have 2 tables were the period columns are differnt and I can't link them so I was wondering how to change the format to reflect 2 digits for the month. The first table shows the date as '1/01/2010' and the second table shows the date as '01/01/2010'. How do I convert the date from the 1st table to show as '01/01/2010'? Basically add a zero in front of the one.Thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-09-23 : 12:29:25
|
| no need of that. if you want to do comparison first convert it to datetime format. I'm not sure your format is mm/dd/yyyy or dd/mm/yyyy so use an appropriate style value based on your formathttp://msdn.microsoft.com/en-us/library/ms187928.aspx------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-24 : 06:25:17
|
Since your format is obviously mm/dd/yyyy you can use the following convert to datetime and then compare the values.for examplewhere convert(datetime,your_datecolumn1,101) = convert(datetime,your_datecolumn2,101) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|