Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 13th, 2004, 07:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default Can I get Date in this format?

Hi,

Is there any way (if at all an easiest apporach), by which I can get the date from my tables in the format shown below using sql? Date values in table refer to IST, so it needs to be converted to GMT in the format given below. As of now I am doing that from the frontend. This is in SQL 7.0

Fri Sep 13 00:00:00 GMT 2004

Thanks for any help in advance.
Cheers!

_________________________
- Vijay G
Strive for Perfection
__________________
- Vijay G
 
Old September 15th, 2004, 04:41 AM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to happytony Send a message via MSN to happytony
Default

hai,

sql server 7 dont have to option of GETUTCDATE()
here i am giving a easy solution in sql 2000 which you can extent to sql server 7 by synchronising with the timebase in the registry



SELECT
LEFT(CAST(DATENAME(DW,GETUTCDATE()) AS Varchar),3) +
' '+
LEFT(CAST(DATENAME(MM,GETUTCDATE()) AS VARCHAR),3)+
' '+
RIGHT('00'+CAST(DATEPART(DD,GETUTCDATE()) AS Varchar),2) +
' '+
Right('00' + CAST(DATEPART(HH,GETUTCDATE()) AS Varchar),2)+
':'+
RIGHT('00' + CAST(DATEPART(MI,GETUTCDATE()) AS VARCHAR),2)+
':'+
RIGHT('00' + CAST(DATEPART(SS,GETUTCDATE()) AS VARCHAR),2)+
' GMT '+
CAST(DATEPART(YYYY,GETUTCDATE()) AS VARCHAR)



Happy Tony
 
Old September 15th, 2004, 10:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Tony,

Thanks. Can you please explain on how do I do that in registry?

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old September 16th, 2004, 01:16 AM
Registered User
 
Join Date: Jul 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to happytony Send a message via MSN to happytony
Default

hai,

The first thing you have to consider here is the accuracy of the time maintained in your system.So you have to first synchronize your system to the time zone
use the atomic clock to update your system according to the time zone from http://www.worldtimeserver.com/

here i am giving the example to get the GMT time from time zone india- calcutta,new-delhi

select getdate() as systemtime
select dateadd(mi,-330,getdate()) as GMTTIME

hope this will solve your problem

HAPPY TONY
 
Old September 16th, 2004, 03:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes Tony, I was aware of doing it that way. But I was looking for something(if available) that could give me the GMT in the format I was looking for. Now understood that with SQL 7.0, I will have to do the formatting on my own.

Thanks much for the help.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
Help with date format gregalb SQL Server 2000 1 February 13th, 2007 10:15 AM
How to give Date format while entering date Subuana Beginning VB 6 4 March 17th, 2006 07:25 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.