
April 11th, 2000, 08:01 AM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
Date Problems
<i><b>Originally posted by : Kevin Byrne (kevinb@terranovamedia.com)</b></i><br />Hi there,<br />I am having some problems and wondered if anyone could help?<br />I have a datetime field in my SQL database which has this format : 4/10/00 12:00:000.<br />I need to strip the time out and rearrange the format of the date.It should look like this: 10/4/00.The date should match a date being supplied by a HTML form.<br />I have tried using DATEPART and concatenating each part of the date with a slash ie "/" and also turning it into a string to try to get it to match using SUBSTRING but I can't seem to be able to query the substring created without putting it into a view....<br />Here is the SQL code:<br />SELECT ITEM_ID,<BR><br />SUBSTRING(<BR><br />CAST(DATEPART(dd,INVOICE_ITEM_WINNING_BIDS.BID_DAT E) AS char(2)) + '/' + <BR><br />CAST(DATEPART(mm,INVOICE_ITEM_WINNING_BIDS.BID_DAT E) AS char(2)) + '/' +<BR><br />CAST(DATEPART(yy,INVOICE_ITEM_WINNING_BIDS.BID_DAT E) AS char(4)),1,9)<BR><br />AS BID<BR><br />FROM <BR><br />INVOICE_ITEM_WINNING_BIDS<BR><br />WHERE<BR><br />BID = "4/10/2000"<BR><br /><BR><br />Any help would be appreciated.<br />Many thanks,<br />Kevin<br /><br /><br />
|