{"id":2978,"date":"2020-10-21T12:35:13","date_gmt":"2020-10-21T11:35:13","guid":{"rendered":"https:\/\/www.snapsurveys.com\/support-snapxmp\/?post_type=epkb_post_type_1&#038;p=2978"},"modified":"2022-01-17T16:04:57","modified_gmt":"2022-01-17T16:04:57","slug":"date-function-examples","status":"publish","type":"epkb_post_type_1","link":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/","title":{"rendered":"Date function examples"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><a id=\"post-2978-_Toc35499232\"><\/a>Using a date function to determine the day of the week of a date<\/h2>\n\n\n\n<p>\n  This example shows the use of the date function weekday. You define a Derived Single Response variable to work out the day of the week for a particular date.\n<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>   Click    <img decoding=\"async\" width=\"26\" height=\"26\" class=\"wp-image-2979\" alt=\"VariablesIcon.png\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png\">    to display the Variables<strong> <\/strong>window. <\/li><li>   Click    <img decoding=\"async\" width=\"25\" height=\"26\" class=\"wp-image-2980\" alt=\"NewSurveyIcon.png\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/newsurveyicon-png-17.png\">    to add a new variable. <\/li><li>   Specify the Variable Details: <ul><li><strong>Name<\/strong>: V6 <\/li><li><strong>Label<\/strong>: Day of the week restaurant visited <\/li><li><strong>Type<\/strong>: Derived (the variable will derive its data from other existing variables). <\/li><li><strong>Response<\/strong>: Single (each respondent will fall into only one of the new codes, as there is only one date of visit per case). <\/li><\/ul><\/li><li>Specify the Code Details: <\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img fetchpriority=\"high\" decoding=\"async\" width=\"558\" height=\"543\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/openendeddate3-png.png\" alt=\"Variable used to categorise time by day of the week\" class=\"wp-image-2981\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\"><li>\n  Click \n  <img loading=\"lazy\" decoding=\"async\" width=\"26\" height=\"26\" class=\"wp-image-2982\" alt=\"SaveIcon.png\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/saveicon-png-18.png\">\n   to save the variable. The variable can then be used in tables and charts in the usual way.\n<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"417\" height=\"338\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/openendeddate4-png.png\" alt=\"Table showing the Visits by day of the week by Age\" class=\"wp-image-2983\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><a id=\"post-2978-_Toc35499233\"><\/a>Calculating age from a date of birth<\/h2>\n\n\n\n<p>\n  These instructions tell you how to create variables to calculate the respondent&#8217;s age from their date of birth and then put the respondents into age bands, based on the difference between a date of birth variable and the date function today. The instructions also apply if you have another date question in the questionnaire, which you want to use instead of today.\n<\/p>\n\n\n\n<p>\n  For this example, the date of birth variable is <strong>Q1a<\/strong>. It assumes a four-digit year.\n<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>   Click    <img loading=\"lazy\" decoding=\"async\" width=\"26\" height=\"26\" class=\"wp-image-2984\" alt=\"VariablesIcon.png\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-12.png\">    to display the Variables<strong> <\/strong>window. <\/li><li>   Click    <img loading=\"lazy\" decoding=\"async\" width=\"25\" height=\"26\" class=\"wp-image-2985\" alt=\"NewSurveyIcon.png\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/newsurveyicon-png-18.png\">    to add a new variable. <\/li><li>   Specify the Variable Details as: <ul><li><strong>Name<\/strong>: Age <\/li><li><strong>Label<\/strong>: Calculated age in years <\/li><li><strong>Type<\/strong>: Derived (the variable will derive its data from other existing variables). <\/li><li><strong>Response<\/strong>: Quantity (the response will be a numeric value for each case). <\/li><\/ul><\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"557\" height=\"390\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/openendeddate5-png.png\" alt=\"Variable to calculate age in years\" class=\"wp-image-2986\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\"><li>   Specify the Code Values to calculate the number of years. Note the use of <strong>\\<\/strong> to extract the whole number of years.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><p>\n  Code\n<\/p><\/td><td><p>\n  Code Label\n<\/p><\/td><td><p>\n  Value\n<\/p><\/td><\/tr><tr><td><p>\n  NA\n<\/p><\/td><td><p>\n  Not Asked\n<\/p><\/td><td><p>\n  Q1a Missing\n<\/p><\/td><\/tr><tr><td><p>\n  OK\n<\/p><\/td><td><p>\n  Valid\n<\/p><\/td><td><p>\n  (today-Q1a)\\365.25 \n<\/p><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\"><li>   Click    <img loading=\"lazy\" decoding=\"async\" width=\"26\" height=\"26\" class=\"wp-image-2987\" alt=\"SaveIcon.png\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/saveicon-png-19.png\">    to save the variable. You can then use this to analyse respondents&#8217; ages. <\/li><li>   The Not Asked value is specified to ensure that the calculation is only performed if data exists for the date question. <\/li><li>   To band the respondents into age groups, create a new variable: <ul><li> <strong>Name<\/strong>: Agegroup <\/li><li><strong>Label<\/strong>: Age groups <\/li><li><strong>Type<\/strong>: Derived <\/li><li><strong>Response<\/strong>: Single (each respondent will only fall into one of the new codes). <\/li><\/ul><\/li><li> Specify the Code Details: <\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"559\" height=\"538\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/openendeddate6-png.png\" alt=\"Variable created to group participants by age\" class=\"wp-image-2988\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"9\"><li>\n  The codes are assigned in order, so all responses that have not been sorted into previous bands appear as 65 plus.\n<\/li><li>\n  Click \n  <img loading=\"lazy\" decoding=\"async\" width=\"26\" height=\"26\" class=\"wp-image-2989\" alt=\"SaveIcon.png\" src=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/saveicon-png-20.png\">\n  to save the variable. \n<\/li><\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Using a date function to determine the day of the week of a date This example shows the use of the date function weekday. You define a Derived Single Response variable to work out the day of the week for a particular date. Click to display the Variables window. Click to add a new variable. [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"epkb_post_type_1_category":[66],"epkb_post_type_1_tag":[],"class_list":["post-2978","epkb_post_type_1","type-epkb_post_type_1","status-publish","hentry","epkb_post_type_1_category-analysing-open-ended"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Date function examples | SnapSurveys<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Date function examples | SnapSurveys\" \/>\n<meta property=\"og:description\" content=\"Using a date function to determine the day of the week of a date This example shows the use of the date function weekday. You define a Derived Single Response variable to work out the day of the week for a particular date. Click to display the Variables window. Click to add a new variable. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"SnapSurveys\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/snapsurveys\" \/>\n<meta property=\"article:modified_time\" content=\"2022-01-17T16:04:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@snapsurveys\" \/>\n<meta name=\"twitter:label1\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/\",\"url\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/\",\"name\":\"Date function examples | SnapSurveys\",\"isPartOf\":{\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png\",\"datePublished\":\"2020-10-21T11:35:13+00:00\",\"dateModified\":\"2022-01-17T16:04:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#primaryimage\",\"url\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png\",\"contentUrl\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png\",\"width\":26,\"height\":26},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Snap XMP Support\",\"item\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp-archive\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Date function examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/#website\",\"url\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/\",\"name\":\"Snap XMP Support Hub\",\"description\":\"Support documentation for Snap Surveys products\",\"publisher\":{\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/#organization\",\"name\":\"Snap Surveys\",\"url\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/06\/snap-surveys-logo-fc.svg\",\"contentUrl\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/06\/snap-surveys-logo-fc.svg\",\"width\":867,\"height\":159,\"caption\":\"Snap Surveys\"},\"image\":{\"@id\":\"https:\/\/www.snapsurveys.com\/support-snapxmp\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/snapsurveys\",\"https:\/\/x.com\/snapsurveys\",\"https:\/\/www.linkedin.com\/company\/snapsurveys\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Date function examples | SnapSurveys","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/","og_locale":"en_GB","og_type":"article","og_title":"Date function examples | SnapSurveys","og_description":"Using a date function to determine the day of the week of a date This example shows the use of the date function weekday. You define a Derived Single Response variable to work out the day of the week for a particular date. Click to display the Variables window. Click to add a new variable. [&hellip;]","og_url":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/","og_site_name":"SnapSurveys","article_publisher":"https:\/\/www.facebook.com\/snapsurveys","article_modified_time":"2022-01-17T16:04:57+00:00","og_image":[{"url":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_site":"@snapsurveys","twitter_misc":{"Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/","url":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/","name":"Date function examples | SnapSurveys","isPartOf":{"@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#primaryimage"},"image":{"@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png","datePublished":"2020-10-21T11:35:13+00:00","dateModified":"2022-01-17T16:04:57+00:00","breadcrumb":{"@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#primaryimage","url":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png","contentUrl":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/10\/variablesicon-png-11.png","width":26,"height":26},{"@type":"BreadcrumbList","@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp\/date-function-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.snapsurveys.com\/support-snapxmp\/"},{"@type":"ListItem","position":2,"name":"Snap XMP Support","item":"https:\/\/www.snapsurveys.com\/support-snapxmp\/snapxmp-archive\/"},{"@type":"ListItem","position":3,"name":"Date function examples"}]},{"@type":"WebSite","@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/#website","url":"https:\/\/www.snapsurveys.com\/support-snapxmp\/","name":"Snap XMP Support Hub","description":"Support documentation for Snap Surveys products","publisher":{"@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.snapsurveys.com\/support-snapxmp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/#organization","name":"Snap Surveys","url":"https:\/\/www.snapsurveys.com\/support-snapxmp\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/#\/schema\/logo\/image\/","url":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/06\/snap-surveys-logo-fc.svg","contentUrl":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-content\/uploads\/2020\/06\/snap-surveys-logo-fc.svg","width":867,"height":159,"caption":"Snap Surveys"},"image":{"@id":"https:\/\/www.snapsurveys.com\/support-snapxmp\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/snapsurveys","https:\/\/x.com\/snapsurveys","https:\/\/www.linkedin.com\/company\/snapsurveys"]}]}},"_links":{"self":[{"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/epkb_post_type_1\/2978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/epkb_post_type_1"}],"about":[{"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/types\/epkb_post_type_1"}],"author":[{"embeddable":true,"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/comments?post=2978"}],"version-history":[{"count":2,"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/epkb_post_type_1\/2978\/revisions"}],"predecessor-version":[{"id":5040,"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/epkb_post_type_1\/2978\/revisions\/5040"}],"wp:attachment":[{"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/media?parent=2978"}],"wp:term":[{"taxonomy":"epkb_post_type_1_category","embeddable":true,"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/epkb_post_type_1_category?post=2978"},{"taxonomy":"epkb_post_type_1_tag","embeddable":true,"href":"https:\/\/www.snapsurveys.com\/support-snapxmp\/wp-json\/wp\/v2\/epkb_post_type_1_tag?post=2978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}