SPSS Statistics

SPSS Statistics

Your hub for statistical analysis, data management, and data documentation. Connect, learn, and share with your peers! 


#Analytics
#SPSSStatistics
#Analyticstools
 View Only
  • 1.  Doing a Select using both Date and Time

    Posted 10/06/24 07:48 PM
    Edited by David Winston 10/06/24 07:57 PM

    I am trying to do a select of records using both date and time using a DATE17 variable. The idea is that I want to select records that would cross both. An example would be selecting a range of records from December 3, 2022 11:30PM to December 4, 2022 1:30AM. I figured out how to do just the dates or do just the time, but I can't figure our how to do them together. Thanks



    ------------------------------
    David Winston
    ------------------------------



  • 2.  RE: Doing a Select using both Date and Time

    Posted 10/06/24 10:30 PM
    The challenge would be how to write  a datetime value to compare with the date variable.
    Something like this would work for that expression
    DATE.DMY(31, 1, 2000) + TIME.hms(22, 10).
    for Jan 31, 2000 22:10



    --





  • 3.  RE: Doing a Select using both Date and Time

    Posted 10/08/24 05:22 AM

    And for the selection, I would use the RANGE function:

    SELECT IF RANGE(datetime,DATE.DMY(3,12,2022)+TIME.HMS(23,30), DATE.DMY(4,12,2022)+TIME.HMS(1,30)).

    No big issue, but RANGE is short and logical.



    ------------------------------
    Robert Lundqvist
    ------------------------------



  • 4.  RE: Doing a Select using both Date and Time

    Posted 10/08/24 10:04 AM

    Thanks to both of you - had the structure for for the date time incorrect was just doing hm instead of hms because was only using hours and minutes. The Range function worked as outlined. Thanks again!



    ------------------------------
    David Winston
    ------------------------------