Date Problem

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 20
Reputation: saurabh_kanwar is an unknown quantity at this point 
Solved Threads: 0
saurabh_kanwar saurabh_kanwar is offline Offline
Newbie Poster

Date Problem

 
0
  #1
Dec 5th, 2006
Hi Guys
I've got a bit of problem with date.
When I transfer data of a table to txt file the date column that appears in the table like "28/03/2001" changes to "28/3/2001 0:00:00" in the txt file. I've tried to change the format of date in the table but it doesn't help.I'm using the following code.


  1. Private Sub Command2_Click()
  2. DoCmd.TransferText acExportDelim, "PESALES Export Specification", "PESALES", "J:\Power Equipment\Common\SK\PESALES.TXT"
  3. End Sub


Thanks for your time
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Date Problem

 
0
  #2
Dec 20th, 2006
this seems more like a code problem than an sql problem. try posting in the appropriate forum for the language you are using. (vbscript?)
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3
Reputation: KeiHimekawa is an unknown quantity at this point 
Solved Threads: 0
KeiHimekawa's Avatar
KeiHimekawa KeiHimekawa is offline Offline
Newbie Poster

Re: Date Problem

 
0
  #3
Jan 9th, 2007
I've been having such problem before. The reason why it chages "28/03/2001" to "28/3/2001 0:00:00" is because SQL requires most date/time parameter to be changed to such format. What I do is use CAST and SUBSTRING to convert the date intolong date.

Example: From "28/3/2001 0:00:00" I chaged it into "March 28, 2001"

Here's the code:
  1. SELECT [whatever's the name of your date field],
  2. CASE WHEN [date field] IS NOT NULL THEN
  3. (SELECT SUBSTRING(CAST([date field] AS VARCHAR), 1, 11))
  4. END AS [new date field name]
  5. FROM [whatever table you're USING]
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS SQL Forum
Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC