Products | Versions |
---|---|
TIBCO Cloud Integration - Connect ( Scribe ) | - |
Example: in the source, the date is defined in SQL server as mydate and type is int and the value is 20050311
Pushing the value using Scribe Online with the formula DATE(LEFT(mydate,4),MID(mydate,5,2), RIGHT(mydate,2))
Gives 3/10/2005 in CRM. (mm/dd/yyyy).
DATE returns a values using the format year,month,day 12.00 am and the format in CRM is define as Englsih (United States), therefore month,day,year.
So, it seems we are off by one day.
The reason is DATE is using UTC and I am in UTC -1. DATE is 3/11/2005 12.0 am UTC and as I am UTC -1, this becomes 3/10/2005 11.00 pm
One possible way to work around it: instead of using DATE, use DATETIME(LEFT(mydate,4), MID(mydate,5,2), RIGHT(mydate,2),1,0,0,2)
See DATETIME:
DATETIME
Syntax
DATETIME (year, month, day, hour, minute, second, kind)
Description
Creates a DateTime using year, month, day, hour, minute, second, kind. Kind is optional and defaults to unspecified if not set.
Arguments
year |
|
A number representing the year. |
|
month |
|
A number representing the month of the year. |
|
day |
|
A number representing the day of the month. |
|
| |||
hour |
|
A number representing the hour of the day. |
|
| |||
minute |
|
A number representing the minute of the 60 minute hour. |
|
| |||
second |
|
A number representing the second of the 60 second minute. |
|
| |||
kind |
|
Indicates whether the time represented by this instance is: |
|
|
Returns
Returns a DateTime.
Example
The following formula creates a new DateTime that can populate a target field.
DATETIME (2014,11,19,14,15,20,0)
Returns: A DateTime object, which represents November 19, 2014 2:15:20 pm UTC/Local set to unspecified.
the last number is kind:
kind Indicates whether the time represented by this instance is:
- 0=unspecified
- 1=UTC
- 2=local
Example when input date is a date
The working example in this article is when the input date is an integer. Here is an example formula when the input date is a date. Set the last parameter "kind" to value 1, so the created datetime will not be changed and no off-by-one-error occurs.
IF(ISNULLOREMPTY(mydate), Null, DATETIME(DATEPART("yyyy", mydate), DATEPART("m", mydate), DATEPART("d", mydate), 0, 0, 0, 1))