MySQL Forums
Forum List  »  Newbie

Changing exisiting data format
Posted by: R B
Date: June 23, 2005 06:28AM

Hi everyone! I have inherited a SQL db which I don't know alot about so I have a question.

There is a VB program that will run a search against the db by 'date'. It works OK except that you receive some old dates because of the way the table searched against is setup. The 'date' field was setup as a varchar(15) type instead of date.

ex. search range of 04-23-2005 thru 04-26-2005 would return those dates but also 04-23-2004 thru 04-26-2004 since those values are greater than those listed in the search. The string searched would be -

select pdate from table where pdate >= '04-23-2005' and pdate <= '04-26-2005';

I would like to change the type from varchar(15) to date but I'm not sure how to go about this. I thought that the date type needed data as yyyy-mm-dd? Is there a way to change the exisiting data to flip it around? Ex. 04-23-2005 is already there and change it to 2005-04-23?

If I could do that for all the pdate values I could edit the VB code to reflect the date format changes and hopefully give more accurate searches for my users!

Thanks for any help and comments!

Options: ReplyQuote


Subject
Written By
Posted
Changing exisiting data format
R B
June 23, 2005 06:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.