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 8756617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:07:26+00:00 2026-06-13T14:07:26+00:00

Possible Duplicate: Convert Month Name to Month Number Function in SQL I am attempting

  • 0

Possible Duplicate:
Convert Month Name to Month Number Function in SQL

I am attempting to convert a month name to month number in the area of the script below called datename(MM, patientinfo.PatientDOB). As an example, it is currently returning as January and I would like it to return as 01 or 1.

From what I’ve read I may need to do a CASE WHEN 'January' THEN 1, but I am not sure where to insert it or the exact syntax to use.

select
    Update_Log.RecordID as 'Dictation ID',
    cast(dictations.DOS as DATE) as 'Date of Service',
    groups.GroupName,
    rtrim(aspnet_Users.Firstname)+' '+rtrim(aspnet_Users.LastName) as Provider, 
    Update_Log.Updated, 
    Update_XRef.columnName as 'Update Type', 
    "New Value" =
        case 
            when update_xref.columnname = 'FacilityID' then (select facility.FacilityName+' [gID:'+update_log.NewValue+']' from facility where update_log.NewValue = facility.FacilityID)
            when update_xref.columnname = 'DOS' then (select left(update_log.NewValue, 11) as 'New Value')
            when update_xref.columnname = 'DictatorID' then (select rtrim(aspnet_users.Firstname)+' '+rtrim(aspnet_users.lastname) from aspnet_Users where aspnet_users.userid1 = update_log.UpdatedBy)
            when update_xref.columnname = 'PatientID' then (select rtrim(patientinfo.PatientFirst)+' '+rtrim(patientinfo.PatientLast)+' ['+datename(MM, patientinfo.PatientDOB)+'/'+datename(DD, patientinfo.PatientDOB)+'/'+datename(YY, patientinfo.PatientDOB)+ ', gID:'+rtrim(patientinfo.PatientID)+']' from patientinfo where patientinfo.PatientID = Update_Log.NewValue)
        end,
    "Old Value" =
        case 
            when update_xref.columnname = 'FacilityID' then (select facility.FacilityName+' [gID:'+update_log.OldValue+']' from facility where update_log.OldValue = facility.FacilityID)
            when update_xref.columnname = 'DOS' then (select left(update_log.OldValue, 11) as 'Old Value')
            when update_xref.columnname = 'DictatorID' then (select rtrim(aspnet_users.Firstname)+' '+rtrim(aspnet_users.lastname) from aspnet_Users where aspnet_users.userid1 = update_log.UpdatedBy)
            when update_xref.columnname = 'PatientID' then (select rtrim(patientinfo.PatientFirst)+' '+rtrim(patientinfo.PatientLast)+' ['+left(datename(MM, patientinfo.PatientDOB),3)+'/'+datename(DD, patientinfo.PatientDOB)+'/'+datename(YY, patientinfo.PatientDOB)+ ', gID:'+rtrim(patientinfo.PatientID)+']' from patientinfo where patientinfo.PatientID = Update_Log.OldValue)
        End
from 
    Update_Log, 
    Update_XRef, 
    aspnet_Users, 
    groups, 
    Dictations
where 
    Update_log.XRefID = Update_XRef.xRefID
    and Update_Log.UpdatedBy = aspnet_Users.userid1
    and aspnet_users.Groupid = Groups.GroupID
    and dictations.Dictationid = Update_Log.RecordID
    and Update_Log.Updated > dictations.DateofSignature
order by 
    groups.GroupName, 
    aspnet_users.LastName, 
    update_log.RecordID
  • 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-13T14:07:28+00:00Added an answer on June 13, 2026 at 2:07 pm

    Assuming patientinfo.PatientDOB is a full & typed date, to get the integer month part of the date;

    datepart(MM, patientinfo.PatientDOB)
    

    or

    month(patientinfo.PatientDOB)
    

    wrapped in cast(?? as varchar(2)) for a character string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Convert Month Number to Month Name Function in SQL Hi .... how
Possible Duplicate: convert month from name to number I have a simple (yet interesting)
Possible Duplicate: Convert a number to the shortest possible character string while retaining uniqueness
Possible Duplicate: Convert tags to html entities I am building a snippets area to
Possible Duplicate: Convert a number range to another range, maintaining ratio So I have
Possible Duplicate: Convert Unixtime to Datetime SQL (Oracle) We have a table of type
Possible Duplicate: MATLAB: convert color name to RGB 3 element vector MATLAB's ColorSpec concept
Possible Duplicate: PHP: convert date format yyyy-mm-dd => dd-mm-yyyy [NOT IN SQL] Right now
Possible Duplicate: PHP: convert date format yyyy-mm-dd => dd-mm-yyyy [NOT IN SQL] Hope everyone
Possible Duplicate: Number formatting: how to convert 1 to 01, 2 to 02, etc.?

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.