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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:19:40+00:00 2026-06-12T09:19:40+00:00

In access , Australian dates in SQL statements are delimited and formatted as #d/m/yyyy#

  • 0

In access , Australian dates in SQL statements are delimited and formatted as #d/m/yyyy#. For example:

SELECT * FROM mytable WHERE mydate BETWEEN #2/1/2001# AND #4/3/2001# AND more...

I need to grab this SQL statement and massage it so I can present it to SQLite as:

SELECT * FROM mytable WHERE mydate BETWEEN '2001-01-02' AND '2001-03-04' AND more...

The task, then, is to convert #xd/xm/yyyy# to 'yyyy-mm-dd'. The “Hello, World!” of regex examples.

Using vbaregexp with .Global = TRUE, I’m able to replace the delimiters and re-order the elements in one step:

vOldPattern = "#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})#"
vNewPattern = "'$3-$2-$1'"

This gives the following intermediate result:

SELECT * FROM mytable WHERE mydate BETWEEN '2001-1-2' AND '2001-3-4' AND more...

I thought I could pad all the single digits with a single pass:

vOldPattern = "-(\d[-'])"
vNewPattern = "-0$1"

but this approach padded only the first (month) digit. I gave up and ran through two passes, matching first on
"-(\d-)"

and then on
"-(\d')"

So, three passes to alter the format and tweak the content. Surely there’s a single search/replace command for this task. Can somebody volunteer a more elegant solution?

And, since I have to compile and export the runtime, I guess I can’t use late binding but instead need to load the reference to the MS VBScript Regular Expressions. I’m developing in Win7/32, but the app needs to be backwards-compatible (compatible?) with WinXP. Which version (1.0 or 5.5) of the VBScript RegEx library should I load?

Cheers!

  • 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-12T09:19:40+00:00Added an answer on June 12, 2026 at 9:19 am

    You can use a positive lookahead to get around padding only the first zero – which I think occurred for you as the last - is consumed in testing for a non-digit for your second -

    So it can be reduced to two patterns as below

    I don’t think it can be done in a single shot but I’d like to see it.

    I used
    2/12/2001
    rather than
    2/1/2001
    to prove the replacement handles mixed strings

    Sub Test()
    Dim strIn As String
    Dim objRegex As Object
    strIn = "SELECT * FROM mytable WHERE mydate BETWEEN #2/12/2001# AND #4/3/2001# AND more"
    Set objRegex = CreateObject("vbscript.regexp")
    With objRegex
    .Global = True
    .Pattern = "#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})#"
    strIn = .Replace(strIn, ("$3-$2-$1"))
    .Pattern = "(-)(\d)(?=[^\d])"
    strIn = .Replace(strIn, "$10$2")
    MsgBox strIn
    End With
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MS ACCESS SQL DELETE * FROM Lane_Details WHERE Lane_Details.Week not in(SELECT DISTINCT TOP 3
In Access, what is the difference between these two statements? DBEngine.BeginTrans and DBEngine.Workspaces(0).BeginTrans The
//ACCESS SELECT DISTINCT products.imageUrl FROM products WHERE ((products.pcprod_ParentPrd=5573) AND (products.pcprod_Relationship LIKE '*441*')); //ASP SELECT
Access 2007 / SQL / VB I have a query: SELECT Count(*) AS CountOfCR1
PHP - Access MSSQL datetime column from the returned array Array ( [0] =>
Using Access 2003 I want to get a table value from the two databases
Root access is possible. Basically I need a way to read content: //settings/system/alarm_alert from
I've got an Access database with a column of dates and times and a
Access PDF files from 'res/raw' or assets folder programmatically to parse with given methods
The access to read from the db has been given to me via mssql

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.