Determining a Time ID from a DateTime field

I have a DT field that I want to break into 1/2hr designators (so 1-48).  Is there a better way to do this than with just a lengthy CASE WHEN (or "old school" IF THEN ELSE)?
So, for example 03/12/2014 12:05:30am becomes 1 (1st half hour after midnight), while 03/12/2014 11:37:33pm would be 48 (last half hour before midnight).
Thanks much!
(fwiw, CR2k8)

Hi Adam,
Create a formula with this code:
If minute({DateTime_Field}) in [0 to 30] then
Datetime(date({DateTime_Field}),time(hour({DateTime_Field}),0,0))
else
If minute({DateTime_Field}) in 31 to 59 then
datetime(date({DateTime_Field}),time(hour({DateTime_Field}),30,0))
else
Datetime(0,0,0,0,0,0)
You can then group on this formula field and set it to Print for each minute.
-Abhilash

Similar Messages

  • Formula for subtracting time from a datetime field

    I have a field that is formatted as a datetime field. I just need to know how to subtract 3.5 hours from this time. How do I write a formula in crystal reports kindly help me.
    Thanks in advance
    Ramakrishna Reddy

    This should do the trick...
    DateAdd("n", -210, {TableName.DateField})
    HTH,
    Jason

  • Concatenate date time and update SQL datetime field

    I have a form that captures date and time in 2 separate fields data and time.
    I need to combine these fileds and UPDATE a SQL database (datetime field)
    The date field is passed like this  DSDATE={ts '2013-11-18 00:00:00'}
    The time field is passed like this   TIME_IN1=14:05
    How do I concatenate DSDATE AND TIME_IN1 so that I can insert like this 2013-11-18 14:05:00.000 ?

    The easiest way may be the best. You judge.
    <cfset DSDATE = parsedatetime('2013-11-18')>
    <cfset  TIME_IN1="14:05">
    <cfset yr = year(DSDATE)>
    <cfset mnth = month(DSDATE)>
    <cfset d = day(DSDATE)>
    <cfset hr = listGetAt(TIME_IN1,1,":")>
    <cfset mn = listGetAt(TIME_IN1,2,":")>
    <cfset datetime=createdatetime(yr,mnth,d,hr,mn,0)>
    <cfoutput>#datetime#</cfoutput>

  • Getting a Time value from a datetime data type in SQL Server - URGENT!

    Hi guys
    I have an urgent issue here -
    I have a datetime data type in a SQL Server database. The field holds both a time, and a date within it.
    I am able to pull the date out of the field by using:
    Date sDate = Date();
    while (gd.next()) {
    sDate = gd.getDate(2);
    how do this with the time????
    Thanks

    Hi,
    The funny part here is that you have already done it! The API is a great thing to use to help in your programming.
    API: The class Date represents a specific instant in time, with millisecond precision.
    You want time, you got it! How about:
    sDate.getTime();
    sDate.getMinutes();
    sDate.getHours();
    sDate.getSeconds();
    Not enough?

  • AppServ Control keeps mangling dateTime fields in WS tests

    I've deployed a web service that takes 2 dateTime fields as parameters. The format of the dateTime fields is xsd:dateTime (YYYY-MM-DDTHH:mm:ss.SSS).
    However, every time I type in a value in the datTime form field, and press the Invoke button, the AS Control mangles the date into a weird format like YYYY-MM-DDTHH:mm:ss.SSS+X.XXX, and the invoke fails with the error message 'Not all form values are valid."
    How do I bypass this bug? Without it, I can't test the web service using the AS Control.

    I'm testing a web service using the ASC.
    The ASC automatically creates a web page with a form in it to enter my test data.
    For a dateTime field, the "helpful" text next to the field's edit box says "xsd:dateTime (YYYY-MM-DDTHH:mm:ss.SSS)"
    So I type in 2007-07-10T23:12:10.000.
    Until this point, the color of the text in the field is "black" to indicate that the syntax is okay.
    I then change focus so that my cursor is in the next field. Or I press the Invoke button... same thing.
    The contents of the dateTime field automatically change to:
    2007-07-10T23:12:10.000-08.0:00
    and the color of the text in the field turns to "red" to indicate that the syntax is bad. And below the Invoke button I see a message that says:
    "Not all form values are valid."
    I try to change the value back to what it was, but the ASC insists on changing it back to the bad value each time I press Invoke or shift focus away from the dateTime field.

  • Getting a null when trying to access DateTime fields (that I've added) from my work item

    I'm getting a null when trying to access (custom) DateTime fields from my work item.
    I've got a customized work item with 'extra' string and datetime fields.
    <FieldDefinition name="Design Version" refname="XXX.DesignVersion" type="String" reportable="dimension" />
    <FieldDefinition name="Date Closed" refname="XXX.DateClosed" type="DateTime" reportable="dimension" />
    This code fails:
    WorkItem workItem = workItemStore.GetWorkItem(workItemId);
    var tt1 = workItem["XXX.DesignVersion"];//works
    var tt3 = workItem["XXX.DateClosed"]; //tt3 == null, fails also for html fields
    Any idea what's up? thanks

    Hi TimB,  
    Thanks for your post.
    What’s the version of your TFS?
    If you open this work item in VS, there’s no date value in your Date Closed field? Please try below code snippet:
    if (wr.Fields["XXX.DateClosed"].Value
    == null)
    Console.WriteLine(wr.Fields["XXX.DateClosed"].Value);
    else
    Console.WriteLine(wr.Fields["XXX.DateClosed"].Value);
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Determine propagation time from signals obtained with Gould Transition software

    Hi
    I'm trying to analyze signals from measurements of sound waves. I tried to do it with the Transition software, but this software is not sufficient because there are no averaging or filter options (furthermore you have to analyze graph after graph). Signals are saved in ASCII-code and what I'm looking for is a good and fast way to determine propagation time from the differences of the arriving of two waves. FFT would be great to.
    Thanks a lot
    Marco

    Any personal experiences would be greatly appreciated.

  • Mysql datetime datatype, from that datetime how can i compar only time part

    Hello i have database table in mysql, there is Datetime datatype column, from that datetime how can i compare only time part .....??
    Thanks in advance...

    Note you can't simply just compare time via equality however.
    Timestamp resolution is to the second or even milli-second. No user wants to match a time to an exact millisecond.
    What they want is something like a match by hour - for example returning the number of transactions that happened from 1pm to 2pm. Even that isn't completely correct because then you need to consider whether 1pm and/or 2pm is inclusive or exclusive. Normally one end will be inclusive and the other exclusive.
    So first you need to define what the period is.
    Then construct the range.
    Then pass the range and, as already mentioned, use specific functions to handle the extraction of the time.

  • Datetime field overflow / String data right truncation

    Hi All,
    Getting the follwing erros while working with timestamp for selecting from or inserting data into DB2 through WebSphere 6.1.
    I am passing values like this: 2006-05-02-21.57.26.744341.
    The queries run fine while executing through some SQL Frontend editor.
    [IBM][CLI Driver] CLI0114E Datetime field overflow. SQLSTATE=22008
    [IBM][CLI Driver] CLI0109E String data right truncation. SQLSTATE=22001
    Please let me know the problem.

    If you are trying to convert to a java.sql.Timestamp as part off the process of inserting into DB2 then Timestamp is derived from java.util.Date which holds the time in milli-seconds but you are providing a microseconds field.
    Could this be the problem?

  • DateDiff Help (Need time difference FROM Time 1 TO Time 2 - one direction)

    I hope I am putting this in the right section. This is my first post. Thank you all ahead of time for your help.
    I am new to both SQL and Report Builder so please bear with me and thank you ahead of time.
    I need to find the time difference (in minutes) between Time 1 and Time 2. I've figured out the basics in how to do this but I need the logic to work in ONE DIRECTION. Meaning I need the statement to find the difference STARTING FROM TIME 1 and then ENDING
    WITH TIME 2. I need the statement to always assume that Time 1 is FIRST and that Time 2 is LAST.
    Here's an example of my results now with a basic DateDiff statement.
    Time 1 | Time 2 | Time Difference (in minutes)
    11:30 | 1/15/2015 11:50:00 AM | 20
    23:50 | 1/15/2015 12:00:00 AM | 1430
    23:45 | 1/15/2014 2:05:00 AM | 1300
    Please note that Time 1 does NOT have a date at all and came over from its table as a simple 4 digit string so I had to convert it to datetime format using a concatenate statement. If it DID have a date then this probably wouldn't be a problem.
    Thoughts?
    Thanks.

    Thanks, Patrick. I'll look into understanding that (I'm still new to both SQL and Report Builder). Could you explain to me what it does?
    I was able to answer my own question only to find that it didn't quite work the way I need it to. I was able to make the logic work so that "if the time is 12AM then change the date for Time 1". However, I ran into another problem and realize that
    I ultimately just need to get this to work in one direction. Meaning I need it to find the difference in time STARTING from the Time 1 field TO the Time 2 field. Here's why (using the statement I got to work but only for 12AM):
    Time 1 | Time 2 | Time Difference (in minutes)
    23:45 | 1/15/2014 2:05:00 AM | -1300

  • REST API - Custom objects DateTime fields

    Hi
    I can't figure out how to create a new custom object record with field of date type. When i'm creating a contact i'm passing string in format like this: "2014-09-29T23:57:08Z". But same format doesn't work with custom objects. It just returns "Invalid JSON string". What am i doing wrong?

    I create successful a custom record within Eloqua using REST API, now I came across a new issue with the time field values !?
    I create the time stamp  from within Salesforce with Long myTime = DateTime.getTime()/1000
    which creates for  "30.11.2014 1:12 PM" the time stamp  "1417353120"
    If I put this value into http://www.unixtimestamp.com/index.php i receive back
    which is the correct time and date so I assume that is the correct Unix time stamp
    well if i pass this value to Eloqua this gets messed up and it show a difference of 5 hours in the view as shown below
    If that would be only a "view" issue I wouldn't be bothered , but if I make a GET call I get back the same wrong Time at that date as I am not getting back a unix time stamp but the
    wrongly converted date.
    Does anyone got a work around for that?
    here is the GET response snip
    {"type":"FieldValue","id":"218","value":"holidays"},{"type":"FieldValue","id":"219","value":"PPV-0878541"},{"type":"FieldValue","id":"192","value":"12\/3\/2014 8:12:00 AM"},{"type":"FieldValue","id":"207","value":"12\/30\/2014 11:12:00 AM"},{"type":"FieldValue","id":"216","value":"12\/4\/2014 8:50:00 AM"},{"type":"FieldValue","id":"217","value":"12\/18\/2014 8:50:00 AM"},{"type":"FieldValue","id":"213","value":"N"},{"type":"FieldValue","id":"208"},{"type":"FieldValue","id":"212","value":"myself"},{"type":"FieldValue","id":"211","value":"11\/30\/2014 8:12:00 AM"},{"type":"FieldValue","id":"209","value":"now
    and below the screenshot of the dates which are messed up but important for us (funny thing is the created and last modified date in small is correct)
    If this 5 hours difference are consistence i would just add 18.000 seconds towards the getTime() / 1000 but this shouldn't be the case should it? I mean the created date time is correct the convertion online is correct so should the unix time stamp value

  • Time reference from variable in crcy transl. type

    Hi guys,
    does anybody know, where to create the variables displayed in RSCUR, when I want to create a crcy. transl. type with time reference from variable?
    Thanks in advance, Clemens

    Hi,
    With  step by step :
    http://www.sapdb.info/wp-content/uploads/2008/11/bw-howtousevariablestimereferencesincurrencyconversion.pdf
    with  steps and Definitions :
    http://www.scribd.com/doc/7061035/How-to-Use-Variables-for-Currency-Conversion
    The time reference for the currency translation can be either fixed or variable.
    If the time reference is fixed, the time at which the exchange rate is determined is independent of the data. You have the following options:
    ○       You can establish that the time reference be determined upon translation.
    ○       You can select the current date.
    ○       You can specify a fixed date as the key date.
    ○       You can specify any variable that exists for InfoObject 0DATE.
    ○       You can establish that the query key date be used. This is determined in the query settings.
    If the time reference is variable, the time at which the exchange rate is determined is decided by a time characteristic value.
    ○       A variable time reference can, for example, be determined using the end or start of a fiscal year or calendar year, a period and a month u2013 or even to the exact day. The following standard time characteristics are available: 0FISCYEAR, 0FISCPER, 0CALYEAR, 0CALQUARTER, 0CALMONTH, 0CALWEEK and 0CALDAY.
    ○       The time reference can also be determined using a customer-specific InfoObject of type date (for example, trading day). Note that this InfoObject has to have the same properties as the standard InfoObject selected in the variable time reference or must reference it.
    ○       You can specify an InfoSet: This is only necessary if you are determining the target currency using an InfoObject that exists in the InfoSet more than once. You enter the field alias so that the InfoObject can be specified uniquely.
    In the Business Explorer, you can only set time variable currency translations in query definition, and not for an executed query. See also Setting Variable Target Currency in the Query Designer.
    ○       In the Time Adjustment field of type INT4, you can specify whole numbers with a +/- sign.
    ○       In the Time Adjustment from Variable field, you can specify formula variables (1FORMULA). As these values of the variables may have to be whole numbers, they are rounded to whole numbers (integers) where necessary.
    The time adjustment (regardless of whether it is fixed or variable) is always related to the InfoObject specified under Variable Time Reference.
    Example of a time adjustment of -3:
    The variable time reference is To the exact day and the InfoObject under Variable Time Reference is 0CALDAY. Instead of 07.11.2006, after the time adjustment, 04.11.2006 is used for the translation.
    The variable time reference is End of Week and the InfoObject under Variable Time Reference is 0CALWEEK. Instead of 52.2004, the week 49.2004 is calculated and the end date is calculated from this.
    For more info pls refer this link:
    http://help.sap.com/saphelp_nw2004s/helpdata/EN/80/1a6806e07211d2acb80000e829fbfe/content.htm
    I hope these will helps you.
    Thanks .
    Hema

  • Sum a DATETIME field

    Just noticed it isn't straight forward to SUM a DATETIME fields.
    I’ve used the following code to get the time, how do I convert the output back to a DATETIME field?
    declare @T table
    total_hours_worked datetime
    insert into @T values ('01:00:00')
    insert into @T values ('01:30:00')
    insert into @T values ('03:35:00')
    select *
    from @T
    select SUM((DATEPART(hh,total_hours_worked)*60)+DATEPART(mi,total_hours_worked)+(DATEPART(ss,total_hours_worked)/(60.0)))/60.0 as TotalHours from @T
    Thanks,

    I should have added the disclaimer that my solution would require total_hours_worked to be stored as either a float or a varchar to be used with the function I described above.   The completed functions would be similar to 
    CREATE FUNCTION dbo.TimeSpan_CreateFromString
    @pFormattedTimeSpan varchar(128) = null
    RETURNS float(53)
    with returns null on null input AS
    BEGIN
    declare @DayPortion int
    ,@HourPortion int
    ,@MinutePortion int
    ,@SecondPortion decimal(6,4)
    declare @l int
    declare @s2 varchar(128)
    DECLARE @Result float(53)
    select @s2=LTRIM(rtrim(@pFormattedTimeSpan))
    set @l = LEN(@s2)
    declare @i int
    if CHARINDEX('.',@s2,1) < CHARINDEX(':',@s2,1)
    begin
    set @i = CHARINDEX('.',@s2,1)
    select @DayPortion =
    case CHARINDEX('.',@s2)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX('.',@s2)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX('.',@s2)-1) as int)
    else 0
    end
    end;
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    end
    else
    begin
    set @DayPortion=0
    end
    -- ** debug: select @i, @l, @s2
    --select CHARINDEX(':',@s2,1) [c1], CHARINDEX(':',@s2,CHARINDEX(':',@s2,1)+1) [c2], CHARINDEX(':',@s2,(CHARINDEX(':',@s2,CHARINDEX(':',@s2,1)+1))+1) [c3]
    set @i = CHARINDEX(':',@s2,1)
    select @HourPortion =
    case CHARINDEX(':',@s2,1)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1) AS int)
    else null
    end
    end
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    -- ** debug: select @i, @l, @s2
    set @i = CHARINDEX(':',@s2,1)
    select @MinutePortion =
    case CHARINDEX(':',@s2,1)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1) AS int)
    else null
    end
    end
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    -- ** debug: select @i, @l, @s2
    set @i = CHARINDEX(':',@s2,1)
    select @SecondPortion =
    case ISNUMERIC(@s2)
    when 0 then null
    else CAST(@s2 as decimal(6,4))
    end
    SELECT @Result = dbo.TimeSpan_CreateFromParts(@DayPortion,@HourPortion,@MinutePortion,@SecondPortion);
    RETURN @Result
    END
    GO
    I changed the function names to make them more consistent.

  • Determine load. time

    Hello Gurus,
    The Determine load. time is  C Default from shipping point in define shipping point - config.
    But I want to know from where the days are defauted as I could not see this in define shipping point itself.
    Please tell me where the load time is mentioned in config to get defaulted.
    thank you
    murali

    Hi Murali krishna,
    Pls find the path where we are going to define the load time below:
    SPRO>Enterprise structure>Definition>Logistics Execution>Define,Copy,delete,check shipping point-->Define shipping point.
    In the screen Determine times tab you can find the field Determine load time with options as (blank,A,B and C).
    If you want to change then select the second option as Copy, delete, check shipping point.Select your shipping point and edit the one you want.
    Regards,
    Mohan.

  • How to get a subset of text from a varchar2 field

    Hello.  I am trying to select a subset of text from a varchar2 field.  This is login information from dba_audit_trail view.  Here's an example of the field (comment_text from dba_audit_trail):
    Authenticated by: DIRECTORY PASSWORD;EXTERNAL NAME: cn=orcladmin,cn=Users,dc=idacorp,dc=local; Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=555.555.555.555)(PORT=99999))
    I am trying to just select the "orcladmin" text - i.e. everything after the first "=" up to the first ","
    I can get everything after the first "=" with this:
    select substr(comment_text, instr(comment_text, '=') + 1) from dba_audit_trail
    ... but I don't know how to stop at the first ","
    Any help would be greatly appreciated.
    Thanks!
    Message was edited by: DRC

    Hi,
    Here's one way to do it:
    WITH got_pos    AS
        SELECT  comment_text    -- and whatever other columns you need
        ,       INSTR (cooment_text, '=')   AS equal_pos
        ,       INSTR (cooment_text, ',')   AS comma_pos
        FROM    dba_auit_trail
        WHERE   ...             -- any filtering goes here
    SELECT  SUBSTR ( comment_text
                   , equal_pos + 1
                   , comma_pos - (equal_pos + 1)
                   )   AS first_cn
    FROM    got_pos
    You could do it without a sub-query; you'd just have to do the exact same INSTR 2 times, where I used equal_pos 2 times.
    You could also get the results you want using regular expressions, such as:
    SELECT  REGEXP_SUBSTR ( comment_text
                          , '=([^,]*),'
                          , 1
                          , 1
                          , NULL
                          , 1
                          )      AS first_cn
    FROM    dba_audit_trail
    Although this uses less code, it's slower than using INSTR and SUBSTR .

Maybe you are looking for