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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:58:38+00:00 2026-05-15T17:58:38+00:00

There is a text field called myDate. This field can contain either 1) ‘Fiscal

  • 0

There is a text field called myDate. This field can contain either 1) ‘Fiscal year ending someDate‘ or 2) ‘dateA to ‘dateB‘.

In situation 1), I want to set the field date1 = to someDate.

In situation 2), I want to set the field date1 = dateA and the field date2 = dateB.

All the dates (someDate, dateA, dateB) can be written as 1/1/2000, Jan 1, 2000, or January 1, 2000.

How do I go about extracting the dates from myDate and inserting them into the correct fields?

  • 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-05-15T17:58:38+00:00Added an answer on May 15, 2026 at 5:58 pm

    This doesn’t look complicated enough to need a “proper” regular expression. Those textual dates can be parsed directly into a DATETIME type by SQL without any mucking around, as you can see by running this query:

    SELECT CAST('1/1/2000' AS DATETIME), CAST('January 1, 2000' AS DATETIME), CAST('Jan 1, 2000' AS DATETIME)
    

    To get -1 year and +1 day, just use DATEADD, e.g.

    SELECT DATEADD(dd, 1, DATEADD(yy, -1, 'January 1 2000'))
    

    …so, all you really need to do is cope with your two different cases and grab the dates out. So, something like:

    SELECT
      CASE 
        WHEN myDate LIKE 'fiscal year ending %' THEN CAST(DATEADD(dd, 1, DATEADD(yy, -1, REPLACE(myDate, 'fiscal year ending ', ''))) AS DATETIME) 
        ELSE CAST(LEFT(myDate, PATINDEX('% to %', myDate)) AS DATETIME)
      END 'FromDate',
      CASE
        WHEN myDate LIKE 'fiscal year ending %' THEN CAST(REPLACE(myDate, 'fiscal year ending ', '') AS DATETIME)
        ELSE CAST(SUBSTRING(myDate, PATINDEX('% to %', myDate) + 4, 100) AS DATETIME)
      END 'ToDate'
    FROM 
      ...whatever
    

    …should do the trick. I’ve not really tested that, but hopefully it’ll give you enough of an idea to see what I’m getting at.

    Note that some of the results will probably depend on the language settings of your server/database. For example, while 1/1/2000 is always going to be 1 Jan, is 3/4/2000 the third of April, or the fourth of March?

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

Sidebar

Related Questions

Is there any way to place an image inside of a text field with
If I want to parse a text field in SSJS there are 2 main
I am focusing on an input field with jQuery: $(input:text).focus(); There is already some
Say, there are two tables. One contains a field with long text values (for
I have a rich text field (called description) which containing texts and images I
I have a text-field called name in my schema.xml . A query q=name:(organic) returns
I have a field called Timestamp, that stores its values as text as opposed
I have table with field called description which contains text like following |Description |
I have a UIAlertView with a text field in it. This view works correctly;
I have a webpage where there are few text fields to be filled up

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.