473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Need to convert a date and time to a different format


Precisely, here's what I need:

When I run getdate(), I get, for example:

August 9 2004 5:17 P.M.

I want to turn the date portion into:

8/9/2004 format and update one column with it
I want to turn 5:17 P.M. into:

hhmmss and update another column with it.
I've been playing around with datepart, with substr, with you name it,
and I'm stumped.

Any code samples, other help most appreciated.

Thanks,
Google Jenny

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
1 2212
Hi

If you column is a datetime data type then there will always be a time
portion. Not specifying the time when you update the field will default it
to 00:00:00. To return a string representation of the date and time you can
use the CONVERT function to specify a format. See the topic "CAST and
CONVERT" in books online. Use the REPLACE function if you want to strip out
the colons.

DECLARE @myDate datetime
SET @myDate = '20040809 17:17'

SELECT @myDate, CONVERT(char(10),@myDate,101) + ' ' +
REPLACE(CONVERT(char(8),@myDate,108),':','')

John

"Google Jenny" <mi******@yahoo.com> wrote in message
news:41**********************@news.newsgroups.ws.. .

Precisely, here's what I need:

When I run getdate(), I get, for example:

August 9 2004 5:17 P.M.

I want to turn the date portion into:

8/9/2004 format and update one column with it
I want to turn 5:17 P.M. into:

hhmmss and update another column with it.
I've been playing around with datepart, with substr, with you name it,
and I'm stumped.

Any code samples, other help most appreciated.

Thanks,
Google Jenny

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
First of all, I want to know if Cookie's expiration time and HTTP's header's last modified time are using the same format. Secondly, how do I format the time from a 10923023324324 kind of number...
3
by: Ralf Meuser | last post by:
Hi there, I get form a database time with the format : 'Jan 01 1900 06:00PM' I want to convert it to :HH:MM I tryed it with $heure=(date("H:i",strtotime($row)) but I get allways 20:55. even...
7
by: Nimmy | last post by:
Hi, I have a file which has different dates, I want to scanf them as CHAR and convert them to DATE format, how can I do this? Thanks
9
by: romy | last post by:
It used to work in vb6. I don't know the syntax in vb.net current date and time.... format (cstr(date),"DDMMYY") format(cstr(time),"HHMM") thanks
2
by: phillip.s.powell | last post by:
I have to migrate data from one database table to another table in another database where the fields do not match, not even in the same order, and even if they do match, on occasions the datatypes...
10
by: bonnie.tangyn | last post by:
Dear all In my ASP page, user can enter date in dd/mm/yyyy format. How can I use Javascript to convert dd/mm/yyyy to yyyy-mm-dd hh:mm:ss. Please give me some advices. Cheers Bon
2
by: kirke | last post by:
Hi, I have a datetime column named dtDateTime. its format is "Oct 27 2006 12:00:00 " I want to group by only date part of it and count my code is $sql1="SELECT ...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
13
by: baldrex | last post by:
hmm... I have something similar to this but in my case this will not work. I have a text field storing the value in mins in this format 000100 representing 1 min. I need to break this into a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.