Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8734015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:45:39+00:00 2026-06-13T09:45:39+00:00

I have a nvarchar(5) column of data that is formatted MMMDD (for example, OCT26).

  • 0

I have a nvarchar(5) column of data that is formatted MMMDD (for example, OCT26). With my select statement, I’d like to convert it to a datetime data type with the current year, and then save that datetime value as an alias, say, UsefulDate. So something like 10-26-2012.

Something like: SELECT (whatever SQL gets the job done) AS UsefulDate

The exact formatting doesn’t matter; I just need to be able to compare two dates together with greater than and less than operators. Also, sometimes the column will be blank. In that case, I’d like to set the alias to blank as well. Is this possible?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:45:40+00:00Added an answer on June 13, 2026 at 9:45 am

    You can convert varchar fields in format MMMDD to date with current year with :

    select convert(datetime,'OCT26'+','+cast(year(getdate()) as varchar),107)
    

    So your query would be something like :

    select convert(datetime,case varcharDate when '' then null else varcharDate end +
                   ','+cast(year(getdate()) as varchar),107) as UsefulDate 
    from table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a column [Cash] nvarchar(50) that has data that will later be converted
I have an XML data type column called tags. In that, I am storing
I have declared a column of type NVARCHAR(MAX) in SQL Server 2008, what would
Basically I have a column named XML that is of type TEXT ; this
I have a flash application that communicates with php to save data to nvarchar(1200)
I need to change the data type of a column from nvarchar(50) to nvarchar(MAX).
I have a table with nvarchar(max) column that may contain xml of known structure.
I have a NVARCHAR(max) column in a table and a stored procedure that would
I have some data that includes a column with delimited data. There are multiple
I have a nvarchar(50) column in a SQL Server 2000 table defined as follows:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.