Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 2014-09-16
Medium Priority
Last Modified: 2014-09-16
how can you change the normal getdate() to the a format like:

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

this is for sql 2012

Question by:25112
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 24

Assisted Solution

by:Phillip Burton
Phillip Burton earned 668 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()
LVL 52

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 664 total points
ID: 40325365
It is this that you want?

Open in new window

LVL 21

Accepted Solution

Randy Poole earned 668 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

Author Comment

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')
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__

Author Comment

ID: 40325478
sorry- I do see it now.

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

thanks all.

Featured Post

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

In this article I will describe the Copy Database Wizard 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.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 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