Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 2D Blocks
  4. Working with Dates

Working with Dates

Scheduled Pinned Locked Moved 2D Blocks
1 Posts 1 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Description

    In the “Sensing” category, there are some new blocks provided by the CreatiCode playground to work with dates.

    677028ab-3468-494b-af90-be080d708baa-image.png

     
     

    The “Date” Block

    You can use the “date” block to convert a text input into a “Date” object:

     
    The input may take any of these 5 formats:
     

    d2.gif

     
     

    Date Calculations

    Once you get the Date object, you can use the operator blocks to run basic calculations on dates.

    For example, you can use the add and subtract blocks to calculate the date that’s some days before or after a date:

    You can also use the subtract block to calculate the number of days between 2 dates:

     
     

    Getting the Day of Week/Day/Month/Year of a Date

    These 4 reporter blocks take the date block as the input, and tell us which day of the week/day/month/year is that date:

    Note that for “day of week”, the value 1 means it is a Monday, and the value 7 means it is a Sunday.

     
     

    Example - The First Monday After Some Date

    For example, suppose we want to know the first Monday after the date August 1st, 2023. We can calculate that date in 3 steps:

    1. We need to find out the day of week for 20230801, which is a Tuesday (value of 2)
    2. We need to calculate how many days are there until the following Monday, which is 6 (8 minus 2)
    3. We need to calculate the date that is 6 days after 20230801, which is 20230807.

    Here are the blocks for the calculation in each step:

     
     

    Days Since 2000 for Date

    You can calculate the number of days since the date of Jan 1st, 2000. This is useful if you need to quickly find out the number of days between 2 dates. For example, there are 10 days between these 2 dates:

    e16c685d-5565-4e02-9d39-607b5d7161e8-image.png

    1 Reply Last reply
    0

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode