cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Weekday

Weekday

KevinD
Established Member

Hello,

I'm trying to retrieve the weekday name or number from a date.

For now I can get the current date and time and extract the time of day. But I would also like to know the name or number of the day, to be able to trigger different actions during the week or the weekend.

KevinD_1-1689251476005.png

 

I have already tried several solutions (formulas with modulo) or several libraries but either the day is not correct or I get an error.

for example: with this code: DayIndex := DTU.GetDayOfWeek(dtDate:=CurentDate , peError:=dateError );

I get this error:

KevinD_0-1689251237314.png

Can anybody help me?

PS: where does the value retrieved by the function: SysTimeRtcGet come from? Is there a way to sync it to the server time? there is a 7 minute difference between the 2

Thanks,

Kevin

 

3 REPLIES 3

Sgilk
Contributor

Hi Kevin,

I was able to get the correct day of the week using the attached application.

Libraries required:

  • CAA Real Time Clock Extern 3.5.17.0
  • CAA DTUtil Extern 3.5.17.0
  • SysTime 3.5.17.0

The error in your image is not a build error, but rather the hardware version in your PLC project does not match the target device. For example, if you are using a ctrlX CORE x3 running PLC 1.20, you should be specifying ctrlX CORE ARM64 1.20 in your PLC project.

The value returned from SysTimeRtcGet is from the ctrlX CORE real time clock. I confirmed this by changing the date of my ctrlX CORE and the weekday returned in the PLC matched. 

What do you mean sync to server time? What is the server? If you assign your browser time to the ctrlX CORE, these should line up. You could also sync to NTP server.

Sgilk_0-1689258770275.png

KevinD
Established Member

Hi Sgilk,

Thanks a lor for your reply !

I'm not at all familiar with the library versions or the CtrlX Core version.

I tried to open your application but I get the following errors:

KevinD_0-1689796959533.png

 

If I press Ignore, I get this :

KevinD_1-1689797015422.png

 

and since I installed the libraries you recommend,

I get errors in my project when I compile:

KevinD_2-1689797142078.png

I've try to follow this tuto : https://developer.community.boschrexroth.com/t5/Store-and-How-to/Update-and-setup-ctrlX-CORE-with-a-...

but I can't acces the collaboration room 

Can you help me to update properly?

I've try other solution from internet like this : 

KevinD_1-1689800424789.png

but RTS_SYSTIMEDATE is empty

EDIT : I manage to get the Weekday with this formula :

KevinD_3-1689800780781.png

I would still like some help with the update 🙂

Thanks,

Kevin

 

 

CodeShepherd
Community Moderator
Community Moderator

Fastest way of updating is to use a system image to  go to the version you like. That is also the recommended way updating from 1.12 to 1.20. See our online documentation how to do so.

General information about versioning see "Release cycle of apps and engineering software".

Information about accessing the ctrlX STORE are in the collaboration room see "FAQ for ctrlX Store".

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist