I have a string "products_2016-05-09" where 2016-05-09 is date appended in the string. I want to extract this date. If the date is minus 1 day I want to display string "products". How can I do this in liquid syntax?
Extracting string and comparing with date
936 Views Asked by Deepika Rajani At
2
There are 2 best solutions below
0
Deepika Rajani
On
The below code worked for me:
{% assign var = {{custom_attribute.${producttype}}} %}
{% assign words = var | split: '_' %}
{% assign yestDate = 'now' | date: "%s" | minus: 86400 | date: "%F" %}
{% assign varDate = words[1] %}
{% if varDate | convert: "date" == yestDate %}
Dynamic String {{words[0]}}
{% else %}
sorry!
{% endif %}
Related Questions in SHOPIFY
- If Else Statements, Javascript Toggle, Liquid / Ruby Language
- meteor-shopify : expected String to be a Hash
- If, elsif, else: Limitations? Liquid
- Add to cart button for Shopify
- Referencing products in blog post?
- Shopify vendor if statement
- How to authenticate Shopify App using Laravel 5
- Issue integrating shopify store with 2checkout in case of non standard currency
- Shopify get current collection
- Shopify list sub-collections
- Wrong redirect URI using shopify-app gem
- Modify theme.liquid using Shopify API
- Shopify APIs and Partner program
- Dynamically Call Shopify Product ID With Jquery Checkbox Type Add To Cart
- Define delayed_jobs dependencies
Related Questions in LIQUID
- Jekyll: Using liquid tags in .md files
- Check if cookie exists using Jekyll Liquid
- How do you get the current time from bigcartel's server?
- If Else Statements, Javascript Toggle, Liquid / Ruby Language
- If, elsif, else: Limitations? Liquid
- sorting of collection does not work
- Shopify vendor if statement
- Jekyll: Liquid Tags used in Sub-directories
- Ruby on Rails liquid theme detect current page and either display banner or not
- Make array elements lowercase with Liquid filters for sorting
- Jekyll - How can I make avoid a paragraph to be added on a YAML frontmatter markdownify item
- Jekyll: Liquid Capture and Markdownify Tag Issues
- Does Liquid have a "does not contain" or "not in array" operator?
- Jekyll Deployment on Github Pages doesn't format correctly (No styling)
- Jekyll and Liquid for-loop
Related Questions in APPBOY
- Android flavor and build variant specific appboy.xml file
- handle button1, button2 click in appboy
- Appboy SDK. How to hide visit indicator for News Feed cards?
- Has anyone successfully used Braze/Appboy with Nuxt.js?
- Rich notification not received when app is force quit
- Category function name collision, how do I specify which category to use?
- When I add the import for mParticle_appboy I get a "No such Module" error
- Appboy SDK iOS, the unreadCardCountForCategories delegate doesn't gives count for an updated card
- How to display Appboy HTML inAppMessage in React JS app
- How to override the behavior of opening Appboy web activity in deeplink In App messge
- RCTEventEmitter payload is null in React Na
- AppBoy iOS push notifications
- Use Custom Event Properties for Canvas Decision Splits in Braze?
- Install and add custom events of @braze/sdk-web package in sails js/node js
- duplicate entry in android studio when using appboy sdk
Related Questions in BRAZE
- Braze <> Snowflake Integration
- Deeplink problem when application working in the background (Braze provider), React Native, iOS
- Received 'BadDeviceToken' (different push-token used by Braze than the one I send them)
- Appboy SDK. How to hide visit indicator for News Feed cards?
- Has anyone successfully used Braze/Appboy with Nuxt.js?
- Rich notification not received when app is force quit
- How to replicate a Braze Canvas Webhook in Salesforce Marketing Cloud
- Appboy SDK iOS, the unreadCardCountForCategories delegate doesn't gives count for an updated card
- How to display Appboy HTML inAppMessage in React JS app
- Braze send data to be displayed in campaign email
- RCTEventEmitter payload is null in React Na
- How to Code Braze Web SDK Content Cards - Tutorial For Beginners
- AppBoy iOS push notifications
- Use Custom Event Properties for Canvas Decision Splits in Braze?
- Cannot get Braze InApp Messages to show up in my appllication
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
To extract the date from the
string, use theremoveandsplitfilters:To check if that product date (
pdate) is within 24 hours (86400 seconds) back, use something like this:Note: This only check if the product date is yesterday (24 hours ago from now) for a more accurate time verification, you need to do more arithmetics. You could also do all of this on the front-end using JavaScript.