Solved

changing format of getdate to include yyy-mon-....

Posted on 2014-09-16
5
168 Views
Last Modified: 2014-09-16
how can you change the normal getdate() to the a format like:
2014Aug1808301403394

specifically, how to change 08 to Aug like in the above example and how to more precision beyond millisecond?

this is for sql 2012

thanks
0
Comment
Question by:25112
5 Comments
 
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 167 total points
ID: 40325361
1. To get "Aug", you should use:

select left(datename(mm,getdate()),3)

2. To get more milliseconds, instead of using Getdate(), you should use:

select sysdatetime()
0
 
LVL 46

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 166 total points
ID: 40325365
It is this that you want?
SELECT CONVERT(VARCHAR, GETDATE(), 109)

Open in new window

0
 
LVL 21

Accepted Solution

by:
Randy Poole earned 167 total points
ID: 40325372
Select format(getdate(),'yyyy MMM dd HH mm ss FFFFFFF')

Open in new window

This will also give you up to 6 digits 3 for milliseconds and 3 for macroseconds
0
 
LVL 5

Author Comment

by:25112
ID: 40325421
thanks - we are getting close.
 
    Select format(sysdatetime() ,'yyyy MMM dd HH mm ss FFFFFFF')
  Select format(GETDATE() ,'yyyy MMM dd HH mm ss FFFFFFF')
  gives
2014 Sep 16 09 46 43 7699724
2014 Sep 16 09 46 43 767 (4 precision less than the above)

what we need is ( without the 2 extra digits with sysdatetime)
2014 Sep 16 09 46 43 767__
0
 
LVL 5

Author Comment

by:25112
ID: 40325478
sorry- I do see it now.


   Select format(sysdatetime() ,'yyyy MMM dd HH mm ss FFFFF')

thanks all.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now