BlockTo.sql 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* syntax version 1 */
  2. pragma UseBlocks;
  3. insert into @t
  4. select
  5. cast(fdate as Date) as `date`,
  6. cast(fdatetime as Datetime) as `datetime`,
  7. cast(ftimestamp as Timestamp) as `timestamp`,
  8. cast(finterval as Interval) as `interval`,
  9. cast(ftzdate as TzDate) as `tzdate`,
  10. cast(ftzdatetime as TzDatetime) as `tzdatetime`,
  11. cast(ftztimestamp as TzTimestamp) as `tztimestamp`,
  12. cast(null as Interval) as `interval_null`,
  13. -cast(finterval_1day as Interval) as `negative_1d`,
  14. from Input;
  15. commit;
  16. select
  17. DateTime::ToDays(`interval`) as interval_to_days,
  18. DateTime::ToHours(`interval`) as interval_to_hours,
  19. DateTime::ToMinutes(`interval`) as interval_to_minutes,
  20. DateTime::ToSeconds(`interval`) as interval_to_seconds,
  21. DateTime::ToMilliseconds(`interval`) as interval_to_msec,
  22. DateTime::ToMicroseconds(`interval`) as interval_to_usec,
  23. DateTime::ToSeconds(`date`) as date_to_seconds,
  24. DateTime::ToSeconds(`datetime`) as datetime_to_seconds,
  25. DateTime::ToSeconds(`timestamp`) as timestamp_to_seconds,
  26. DateTime::ToSeconds(`tzdate`) as tzdate_to_seconds,
  27. DateTime::ToSeconds(`tzdatetime`) as tzdatetime_to_seconds,
  28. DateTime::ToSeconds(`tztimestamp`) as tztimestamp_to_seconds,
  29. DateTime::ToMilliseconds(`date`) as date_to_msec,
  30. DateTime::ToMilliseconds(`datetime`) as datetime_to_msec,
  31. DateTime::ToMilliseconds(`timestamp`) as timestamp_to_msec,
  32. DateTime::ToMilliseconds(`tzdate`) as tzdate_to_msec,
  33. DateTime::ToMilliseconds(`tzdatetime`) as tzdatetime_to_msec,
  34. DateTime::ToMilliseconds(`tztimestamp`) as tztimestamp_to_msec,
  35. DateTime::ToMicroseconds(`date`) as date_to_usec,
  36. DateTime::ToMicroseconds(`datetime`) as datetime_to_usec,
  37. DateTime::ToMicroseconds(`timestamp`) as timestamp_to_usec,
  38. DateTime::ToMicroseconds(`tzdate`) as tzdate_to_usec,
  39. DateTime::ToMicroseconds(`tzdatetime`) as tzdatetime_to_usec,
  40. DateTime::ToMicroseconds(`tztimestamp`) as tztimestamp_to_usec,
  41. DateTime::ToDays(`interval_null`) as interval_null,
  42. /* Overflow test */
  43. DateTime::ToDays(`negative_1d`) as negative_1d,
  44. from @t;