Use list functions and CreateDate() to convert you string into a date
object, then use DatePart() or Month():

myDateObj = CreateDate(ListGetAt(str, 3, '/'), ListGetAt(str, 2, '/'),
ListGetAt(str, 1, '/'));
foo = DatePart(myDateObj);

Lots of CF functions expect a date object, but if you pass them a
string then they will "helpfully" try to process them with unexpected
results, as you've found out with DatePart(). DateFormat() is another:
this is for converting data objects into strings of the specified
format, not the other way round.
 
HTH
Bert

ps Also, you mention you're storing your dates in the database in
format dd/m/yyyy. You'd be well advised to start storing dates in
columns of datatype "date", and use dateFormat() when displaying them
to users.


On 5/31/05, Mark Henderson <[EMAIL PROTECTED]> wrote:
> I want to extract the month from a date that is in the format dd/m/yyyy,
> so I've tried using DatePart (access is the database format). The
> problem I have is that, by default, DatePart always seems to presume the
> entry is in the m/dd/yyyy format and thus, it's setting the month from
> the day (where possible).
> 
> An example: from 12/02/2005 (12th February 2005) DatePart will select
> the 12 as the month. From 25/02/2005, it obviously works correctly, due
> to a lack of alternatives.
> 
> Actually, my situation is slightly more complicated in that this is
> actually used to submit events to a calendar table in the database.
> Start_date is currently in the above mentioned dd/m/yyyy format and that
> is the way I wish to keep things (to save confusion for those
> submitting). So my question  - can this be achieved, and if so,
> how...any ideas?
> 
> A worst case scenario means I will just have to alter the form thats
> entered, but this (DatePart) is something I might like to use in the
> future, so I figured I would ask. All help appreciated.
> 
> TIA
> Mark
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:208030
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to