Jun 17, 2003 #1 nread Technical User Joined Oct 31, 2001 Messages 58 Location GB Hi all, Does anyone know if there is a simple way to select from a datetime field, something similar to that of TRUNC in Oracle... I'm fairly new to SQL Server and seem to being having an absoloute nightmare with dates....!! Any suggestions welcome.... Cheers
Hi all, Does anyone know if there is a simple way to select from a datetime field, something similar to that of TRUNC in Oracle... I'm fairly new to SQL Server and seem to being having an absoloute nightmare with dates....!! Any suggestions welcome.... Cheers
Jun 17, 2003 #2 ClaireHCM IS-IT--Management Joined Mar 26, 2003 Messages 772 Location US Can you be more specific.Please give some example about your desired result. Upvote 0 Downvote
Jun 17, 2003 #3 mit99mh Programmer Joined Sep 24, 2002 Messages 246 Location GB Do you mean trim certain fields off? This trims 1st to 17th character date in UK format. SUBSTRING(CONVERT(VarChar, dateTimeField, 113), 1, 17) AS 'someDate', Try Programs -> SQL Server -> Books Online SUBSTRING CAST CONVERT Hope this helps a bit Upvote 0 Downvote
Do you mean trim certain fields off? This trims 1st to 17th character date in UK format. SUBSTRING(CONVERT(VarChar, dateTimeField, 113), 1, 17) AS 'someDate', Try Programs -> SQL Server -> Books Online SUBSTRING CAST CONVERT Hope this helps a bit
Jun 17, 2003 1 #4 SQLBill MIS Joined May 29, 2001 Messages 7,777 Location US You don't even need the substring command: convert(varchar(17), getdate(), 113) does the same thing as mit99mh's suggestion. -SQLBill Upvote 0 Downvote
You don't even need the substring command: convert(varchar(17), getdate(), 113) does the same thing as mit99mh's suggestion. -SQLBill
Jun 17, 2003 #5 mit99mh Programmer Joined Sep 24, 2002 Messages 246 Location GB Cheers for that Bill - its way better than my suggestion Upvote 0 Downvote
Jun 17, 2003 Thread starter #6 nread Technical User Joined Oct 31, 2001 Messages 58 Location GB Cheers all, I needed to set the time to be 00:00:00 using CAST(FLOOR(CAST(dtmDate AS FLOAT)) AS DATETIME). I am now using Bills suggestion, thanks Bill.... Upvote 0 Downvote
Cheers all, I needed to set the time to be 00:00:00 using CAST(FLOOR(CAST(dtmDate AS FLOAT)) AS DATETIME). I am now using Bills suggestion, thanks Bill....