Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, November 26, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: check if European date if so convert to US date
Brian Kempe
Posts: 53
 
check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Oct 06 12:04 PM
fiogf49gjkf0d
We have a custom field in which we capture a date. Our foreign offices using European date format in their windows are writing dates like this :” 27/10/2006 14:53”. This is crashing the comparison I later try to perform in knowledge sync. I would like to know how, within the plugin script I can check to see if the date given is in Europe format and reformat it US. I am using a simple datetimepicker.
Thank you
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Oct 06 1:48 PM
fiogf49gjkf0d
What version of SalesLogix are you running?
Is the custom field defined as a DateTime field?
Is the date value being updated via SQL or from the data bound control?
[Reply][Quote]
Brian Kempe
Posts: 53
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Oct 06 4:17 PM
fiogf49gjkf0d
Hi, Thanks for reply.
I am running 6.2.4.1015
I am using userfield 5 on ticketactivities table
and it is a databound TdateimeEdit box


Thanks
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 31 Oct 06 6:23 PM
fiogf49gjkf0d
Userfield5 is a vchar(80) so the text value in the control is getting stored in the database.

Some ideas:
1. add a date time field to the database and bind the datatime object to it. The value saved will then be a GMT based date.

2. write your own handler to reformat the values,based on the user's timezone, on the way to/from the database.
[Reply][Quote]
Brian Kempe
Posts: 53
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 01 Nov 06 1:36 PM
fiogf49gjkf0d
Kewl I can easily add an extended table with a datetime field. I will do that.
But, if anybody has an example of code to reformat values, so I can learn how that would be appreciated.

Thanks for your help
[Reply][Quote]
Jeff Crawford
Posts: 52
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Nov 06 9:48 AM
fiogf49gjkf0d
SQL

Syntax
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )

Example
CONVERT(datetime, UserField5, 101)

101-USA-mm/dd/yy
103-British/French-dd/mm/yy

--------------------------------------------------------------

VBA

Syntax
CDate ( Date )
FormatDateTime ( Date [, NamedFormat ] )

Example
FormatDateTime(CDate(Date), 3)

vbShortDate-2-Display a date using the short date format: like the default (mm/dd/yy)
vbLongTime-3-Display a time using the time format: hh:mm:ss PM/AM

(This one should use your regional settings to determine the date format it uses.)
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 06 2:40 PM
fiogf49gjkf0d
Just to play devil's advocate for a second here: Does this field have both Euro and US dates? If so there is no reliable way to convert them. Why? 1/10/2006 is either January 10th (US) or October 1st (Euro). 31/10/2006 on the other hand is pretty obvious because the Euro day exceeds the US month.
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 06 3:12 PM
fiogf49gjkf0d
If the underlying field is a datetime field and the users interact with a data bound datetime object then everything should work.

When information is stored it will be stored as a datetime value adjusted to GMT. When information is displayed it will be reformatted according to the user's timezone and regioinal settings.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 06 4:02 PM
fiogf49gjkf0d
When a locale-specific date is entered into a datetime, is it automatically converted to the ISO date SQL uses? If so then any datetime field would be correct.

The problem I addressed specifically dealt with this instance, a vchar(80) stored string representation of the date. Omitting the obvious data integrity issue with just the separator alone (- vs /), it is almost impossible to determine if 1/10/2006 is in US or Euro if the field has a combination of both types.

One could use cues to help. If the 1st field is above 12, it's definitely a Euro date. If the modifyuser is a userid in Europe, chances are the date is in that format but that's not guaranteed. They could have touched a record created with a US date and didn't modify it to suit their locale. There may be other cues if you're lucky, like all Euro dates are in dd-mm-yyyy instead of dd/mm/yyyy but that doesn't seem to be the case from the example given.
[Reply][Quote]
Frank Chaffin
Posts: 475
 
Re: check if European date if so convert to US dateYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Nov 06 4:13 PM
fiogf49gjkf0d
Jeremy,
Sorry I did not realize that you were talking about the complexities of parsing the varchar(80) field. Your comments present more reasons to store the values in a datetime field.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/26/2024 10:55:52 PM