Date Conversion (UK format vs. US format)

rpremaza

New Member
Joined
Apr 4, 2006
Messages
15
Hello All.
I'm (attempting) to put together a macro will reference a "start date" cell and an "end date" cell. The macro will contain SQL that will hit a sybase database and extract the needed info. Here is my problem. All the dates in the sybase DB are stored in UK format (yyyy-mm-dd). I've formated the 2 cells to this format, the macro is still seeing them in the windows fromat (mm/dd/yyyy). Now I know if I go into control panel and change the format to the UK format my macro works.
QUESTION: Is there something I can do in the macro so that I can get the UK date format and the US format date to work correctly, some type of conversion code would be great.

If it helps, here is the SQL code that I'm using:
select distinct n.statdate, a.lastname+','+a.firstname, q.primaryagent, q.sharepct, p.policyid, c.lastname+','+c.firstname, p.plantype, l.basicface, p.annprem, p.targetprem, p.fyc, p.premmode, p.ex1035prem, p.stat, a.gano, n.Status from dba.policy p, dba.nbapphistory n, dba.polagent q, dba.life l, dba.contact a, dba.contact c, dba.ltc m where (n.StatDate>=? And N.StatDate<=?)and (n.status = '93' or n.status = 18) and n.policyno = p.policyno and n.policyno = q.policyno and n.policyno *= l.policyno and q.agentno = a.clientno and p.clientno = c.clientno order by a.gano,p.policyid, p.stat

(the section : "(n.StatDate>=? And N.StatDate<=?)" is generating a prompt for the date. This is sort of working, but the requirements that I have specify that the dates should be in cells, and the macro pulls from those cells)

Thanks to all
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top